package com.ruoyi.web.service.warning.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.web.domain.warning.FactorMapping;
import com.ruoyi.web.mapper.warning.FactorMappingMapper;
import com.ruoyi.web.service.warning.FactorMappingService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 因子映射关系 服务实现类
 * @author fwx
 * @date 2024-02-03 14:32:28
 */
@Service
@DataSource(value = DataSourceType.SLAVE)
public class FactorMappingServiceImpl extends ServiceImpl<FactorMappingMapper, FactorMapping> implements FactorMappingService {
    /**
    * 新增因子映射关系
    */
    @Override
    public void insert(FactorMapping FactorMapping){
        super.save(FactorMapping);
    }

    /**
    * 修改因子映射关系
    */
    @Override
    public void update(FactorMapping FactorMapping){
        super.updateById(FactorMapping);
    }

    /**
    * 删除因子映射关系
    */
    @Override
    public void delete(String id){
        super.removeById(id);
    }

    @Override
    public List<FactorMapping> getByFactorKey(List<String> keys){
        QueryWrapper<FactorMapping> query  = new QueryWrapper<>();
        query.lambda().in(FactorMapping::getFactorKey,keys);
        List<FactorMapping> list = super.list(query);
        return list;
    }


    /**
    *  分页查询因子映射关系
    */
    @Override
    public void queryPage(IPage<FactorMapping> page){
        QueryWrapper<FactorMapping> query  = new QueryWrapper<>();
        super.page(page,query);
    }

    /**
    * 查询所有因子映射关系
    */
    @Override
    public List<FactorMapping> queryAll(){
        QueryWrapper<FactorMapping> query  = new QueryWrapper<>();
        List<FactorMapping> list = super.list(query);
        return list;
    }

    /**
    * 根据id查询因子映射关系
    */
    @Override
    public FactorMapping findById(String id){
        FactorMapping res = super.getById(id);
        return res;
    }

}
